/**
 * Copyright 2021 xpstem.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.xpstem.lelink.command;

import com.xpstem.lelink.enums.CommandCode;
import com.xpstem.lelink.enums.ReplyStatus;
import com.xpstem.lelink.enums.ReplyType;

/**
 * EV3 command reply package
 * @author billy zhang
 */
public class EV3ReplyPackage {

    private ReplyType type;
    private ReplyStatus status;
    private CommandCode code;
    private int counter;

    /**
     * 回复的原始包数据
     */
    private byte[] rawData;
    /**
     * 回复的命令/操作数据
     */
    private byte[] payload;

    public EV3ReplyPackage(int counter, byte[] rawData) {
        this.counter = counter;
        this.rawData = rawData;
    }

    public ReplyType getType() {
        return type;
    }

    public ReplyStatus getStatus() {
        return status;
    }

    public byte[] getRawData() { return rawData; }

    public void setType(ReplyType type) {
        this.type = type;
    }

    public void setStatus(ReplyStatus status) {
        this.status = status;
    }

    public void setCode(CommandCode code) {
        this.code = code;
    }

    public boolean success() {
        return status == ReplyStatus.SUCCESS;
    }

    public void setPayload(byte[] payload) { this.payload = payload; }

    public byte[] getPayload() { return payload; }

    public CommandCode getCode() { return code; }

    public int getCounter() { return counter; }
}
